package cn.jsj.cxsys.dao.dynamicSQL;

import org.apache.ibatis.type.*;
import java.sql.*;

public class BlobToStringHandler extends BaseTypeHandler<String>
{
    public void setNonNullParameter(final PreparedStatement ps, final int i, final String parameter, final JdbcType jdbcType) throws SQLException {
        ps.setString(i, parameter);
    }

    public String getNullableResult(final ResultSet rs, final String columnName) throws SQLException {
        final Blob blob = rs.getBlob(columnName);
        return new String(blob.getBytes(1L, (int)blob.length()));
    }

    public String getNullableResult(final ResultSet rs, final int columnIndex) throws SQLException {
        final Blob blob = rs.getBlob(columnIndex);
        return new String(blob.getBytes(1L, (int)blob.length()));
    }

    public String getNullableResult(final CallableStatement cs, final int columnIndex) throws SQLException {
        final Blob blob = cs.getBlob(columnIndex);
        return new String(blob.getBytes(1L, (int)blob.length()));
    }
}